home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Found / FWString / Sources / SLLocale.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  1.8 KB  |  62 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                SLLocale.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFound.hpp"
  11.  
  12. #ifndef SLLOCALE_H
  13. #include "SLLocale.h"
  14. #endif
  15.  
  16. #if defined(FW_BUILD_MAC) && !defined(__SCRIPT__)
  17. #include <Script.h>
  18. #endif
  19.  
  20. #ifdef FW_BUILD_MAC
  21. #pragma segment Strings
  22. #endif
  23.  
  24. //========================================================================================
  25. // FW_MacScriptIsSingleByte
  26. //========================================================================================
  27.  
  28. #ifdef FW_BUILD_MAC
  29. static FW_Boolean FW_MacScriptIsSingleByte(short script)
  30. {
  31.     static short gCachedScriptCode = smRoman;
  32.     static long gCachedScriptIsSingleByte = true;
  33.     if (script != gCachedScriptCode)
  34.     {
  35.         gCachedScriptCode = script;
  36.         long flags = GetScriptVariable(script, smScriptFlags);
  37.         gCachedScriptIsSingleByte = (flags & (1L<<smsfSingByte))!=0;
  38.     }
  39.     return gCachedScriptIsSingleByte;
  40. }
  41. #endif
  42.  
  43. //========================================================================================
  44. // FW_LocaleIsSingleByte
  45. //========================================================================================
  46.  
  47. FW_Boolean FW_LocaleIsSingleByte(FW_Locale locale)
  48. {
  49. #ifdef FW_BUILD_MAC
  50.     return FW_MacScriptIsSingleByte(locale.fScriptCode);
  51. #elif defined FW_BUILD_WIN
  52.     return true;
  53.  
  54.     // Someday, the code will look something like this:
  55.     //CPINFO cpinfo;
  56.     //GetACP(locale, &cpinfo);
  57.     //return cpinfo.MaxCharSize == 1;
  58.     // If GetACP might be expensive, it might be worthwhile mimicking the above
  59.     // routine which caches the result of the last call.
  60. #endif
  61. }
  62.